package Exercise1;

import java.util.Random;

public class PersonTest {
    public static void main(String[] args) {
        Person p1 = new Person("乔峰", 100);
        Person p2 = new Person("潘天鸿", 100);
        Random r = new Random();
        while (p1.getBlood() > 0 && p2.getBlood() > 0) {
            int r1 = r.nextInt(15);
            int r2 = r.nextInt(20);
            p2.setBlood(p2.getBlood() - r1);
            if (p2.getBlood() > 0) {
                System.out.println("乔峰拿起拳头打了潘天鸿一下，造成了" + r1 + "的伤害,潘天鸿还剩下" + p2.getBlood() + "的血量");
            }else{
                System.out.println("乔峰拿起拳头打了潘天鸿一下，造成了" + r1 + "的伤害,潘天鸿（虚拟）挂了");
                System.out.println("游戏结束乔峰获胜");
                break;
            }
            p1.setBlood(p1.getBlood() - r2);
            if (p1.getBlood() > 0) {
                System.out.println("潘天鸿拿起拳头打了乔峰一下，造成了" + r2 + "的伤害,乔峰还剩下" + p1.getBlood() + "的血量");
            } else {
                System.out.println("潘天鸿拿起拳头打了乔峰一下，造成了" + r2 + "的伤害,乔峰挂了");
                System.out.println("游戏结束潘天鸿获胜");
                break;
            }
        }


    }


}
